<!DOCTYPE HTML>
<html>

<head>
  <title>How things are made</title>
  <meta name="description" content="website description" />
  <meta name="keywords" content="website keywords, website keywords" />
  <meta http-equiv="content-type" content="text/html; charset=windows-1252" />
  <link rel="stylesheet" type="text/css" href="style/style.css" title="style" />
</head>
<?php
session_start();
?>
<body>
      <div id="header">
      <div id="logo">
        <div id="logo_text">
          <!-- class="logo_colour", allows you to change the colour of the text -->
          <h1><a href="index.php">how things are<span class="logo_colour">Made</span></a></h1>
          <h2>Simple.Different.Creative.</h2>
          </div> 
          
         </div>
      <div id="menubar">
        <ul id="menu">
          <!-- put class="selected" in the li tag for the selected page - to highlight which page you're on -->
           <li><a href="index.php">Home</a></li>
           <li><a href="profileread.php">My Profile</a></li>
          <li class="selected"><a href="addarticle.php">Add Posts</a></li>
          <li><a href="searcharticle.php">Search Posts</a></li>
          <li><a href="searchuser.php">Search User</a></li>
          <li><a href="sendEmail.php">Contact Us</a></li>
        </ul>
      </div>
    </div>
    <div id="site_content">
      <div class="sidebar">
        <!-- insert your sidebar items here -->
        <h3>Latest User</h3>
<h4>Click to see the user registered details</h4>
        <h5></h5>
        <p>
        <?php
		
		DEFINE ('DB_USER', 'root');
		DEFINE ('DB_PASSWORD', '');
		DEFINE ('DB_HOST', 'localhost');
		DEFINE ('DB_NAME', 'SITEDATABASE');
	
		// Make the connection:
		$dbc = @mysqli_connect (DB_HOST, DB_USER,DB_PASSWORD, DB_NAME) 
		OR die ('Could not connect to MySQL: ' .mysqli_connect_error());
		
		$q = "select * from users ORDER BY registrationtime DESC LIMIT 1";
		$r = @mysqli_query($dbc,$q);
		if($r)
		{
			$row=mysqli_fetch_array($r,MYSQLI_ASSOC);
			
		
		
		
        echo '<p>Click here to see user details<br /><a href="http://localhost/MyBlog/showuser.php?other_user_id='.$row['user_id'].'">'.$row['fname'].' '.$row['lname'].'</a></p>';
		
        echo '<p></p>';
		}
		
		?>
        </p>
        <p></p>
        <h4>Sponsored Links</h4>
        <h5></h5>
        <p>This space is reserved for 5 advertisement links</p>
        <h3>Social Media Links</h3>
        <ul>
          <div class="footer_text">
         <div class="foot_pad">
          <div class="link1"><a href="http://www.facebook.com/pages/How-Things-Are-Made/377142059843?sk=wall"> Be a fan on Facebook</a></div>
          <div class="link2"><a href="#">Follow us on Twitter</a></div>
          <div class="link3"><a href="logout.php">Logout</a></div>
          </div>
          </div>
        </ul>
        
      </div>
      <div id="content">
        <!-- insert the page content here -->
       <?php

if(!$_SESSION['email']){
	
	header("Location: http://localhost/MyBlog/login.php");

}
else
{
	$email = $_SESSION['email'];
	echo "Welcome " . $email;
	
	
	if(isset($_POST['submitted']))
	{
		$subject=$_REQUEST['subject'];
		$content=$_REQUEST['content'];
		//$image_name=$_FILES['upload']['name'];
		
		//echo 'The file name is '.$image_name.'';
		
		
		$q="insert into userposts(user_email,subject,content) VALUES('$email','$subject','$content')";
		$r=@mysqli_query($dbc,$q);
		echo "Submitting";
		if($r)
		{
			echo "Post submitted";
			header("Location: http://localhost/MyBlog/index.php");
		}
		else
		{
			echo "POst not submitted";
		}
		
	}
	
}
?>
	<form enctype="multipart/form-data" action="addarticle.php" method="post">
<center><p>Subject: <input type="text" name="subject" size="75" maxlength="350" /></p></center>
<p>Content	<textarea name="content" rows="20" cols="58"></textarea>
</p>

<p>	<input type="submit" name="submit" value="submit" />
    <input type="hidden" name="submitted" value="1" />
    <input type="reset" name="reset" value="reset" /></p>
</form>


       
      </div>
    </div>
    <div id="content_footer"></div>
    <div id="footer">
      Copyright &copy; 2011 | howthingsaremade.com <a href=" ></a> | <a href="" ></a> | <a href=" ></a>
    </div>
  </div>
<div style="text-align: center; font-size: 0.75em;">  <a href="	http://facebook.com/howthingaremade.com"> Designed for E-Business</a>.</div></body>
</html>
